package com.skyolder.milkbee.service;

import com.skyolder.milkbee.domain.Forum;
import com.skyolder.milkbee.repository.ForumRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;

import javax.inject.Inject;
import java.util.List;

/**
 * Service Implementation for managing Forum.
 */
@Service
@Transactional
public class ForumService {

    private final Logger log = LoggerFactory.getLogger(ForumService.class);
    
    @Inject
    private ForumRepository forumRepository;

    /**
     * Save a forum.
     *
     * @param forum the entity to save
     * @return the persisted entity
     */
    public Forum save(Forum forum) {
        log.debug("Request to save Forum : {}", forum);
        Forum result = forumRepository.save(forum);
        return result;
    }

    /**
     *  Get all the forums.
     *  
     *  @param pageable the pagination information
     *  @return the list of entities
     */
    @Transactional(readOnly = true) 
    public Page<Forum> findAll(Pageable pageable) {
        log.debug("Request to get all Forums");
        Page<Forum> result = forumRepository.findAll(pageable);
        return result;
    }

    /**
     *  Get one forum by id.
     *
     *  @param id the id of the entity
     *  @return the entity
     */
    @Transactional(readOnly = true) 
    public Forum findOne(Long id) {
        log.debug("Request to get Forum : {}", id);
        Forum forum = forumRepository.findOne(id);
        return forum;
    }

    /**
     *  Delete the  forum by id.
     *
     *  @param id the id of the entity
     */
    public void delete(Long id) {
        log.debug("Request to delete Forum : {}", id);
        forumRepository.delete(id);
    }
}
